using System;
using System.Collections.Generic;

namespace DemoClasses;

/// <summary>
/// Represents a person with basic information and contact details
/// </summary>
public class Person
{
    private int _age;

    public string Name { get; set; } = string.Empty;
    public string? Email { get; set; }
    public DateTime DateOfBirth { get; set; }

    public int Age
    {
        get => _age;
        set
        {
            if (value < 0)
                throw new ArgumentException("Age cannot be negative");
            _age = value;
        }
    }

    public Person()
    {
        Name = "Unknown";
        DateOfBirth = DateTime.Now;
    }

    public Person(string name, int age)
    {
        Name = name;
        _age = age;
        DateOfBirth = DateTime.Now.AddYears(-age);
    }

    public string GetFullInfo()
    {
        return $"{Name} ({Age} years old)";
    }

    public bool IsAdult()
    {
        return Age >= 18;
    }

    public void CelebrateBirthday()
    {
        Age++;
    }
}
